cmake_minimum_required(VERSION 3.13)

project(cpp_example LANGUAGES C CXX VERSION 1.0.0)

message(STATUS "cpp_example version: ${PROJECT_VERSION}")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

option(COMPILEOPTIONS "Enable CompileOptions Support" ON)


set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 系统检测
include(SystemDetection)

# 开发时请注释这一行, 不要屏蔽警告, 追求0Warning
add_compile_options(-w)

MESSAGE(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS})
MESSAGE(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS "CMAKE_EXE_LINKER_FLAGS: " ${CMAKE_EXE_LINKER_FLAGS})

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../run)

MESSAGE(STATUS "Project source directory: " ${PROJECT_SOURCE_DIR})
MESSAGE(STATUS "Project binary files output path: " ${PROJECT_BINARY_DIR})
MESSAGE(STATUS "Project executable files output path: " ${EXECUTABLE_OUTPUT_PATH})
MESSAGE(STATUS "Project library files output path: " ${LIBRARY_OUTPUT_PATH})

set(ROOT_DIR "${PROJECT_SOURCE_DIR}")
message(STATUS "ROOT_DIR 根目录 - ${ROOT_DIR}")
set(3RD_DIR "${ROOT_DIR}/3rd")
message(STATUS "3RD_DIR 第三方库目录 - ${3RD_DIR}")
set(LIB_DIR "${PROJECT_SOURCE_DIR}/lib_wrapper")
message(STATUS "LIB_DIR KS依赖库目录 - ${LIB_DIR}")
set(DIST_DIR "${LIBRARY_OUTPUT_PATH}")
message(STATUS "DIST_DIR 产物生成目录 - ${DIST_DIR}")

include(GitInfo)
generate_git_info(
	ROOT_DIR ${ROOT_DIR}
)

configure_file(
	"${ROOT_DIR}/version.h.in"
	"${ROOT_DIR}/version.h"
)

option(USE_SPDLOGGER "Use SpdLogger implementation" OFF)
option(USE_CUSTOMLOGGER "Use CustomLogger implementation" OFF)

if(USE_SPDLOGGER AND USE_CUSTOMLOGGER)
    message(FATAL_ERROR "Only one logger can be selected. Please choose either USE_SPDLOGGER or USE_CUSTOMLOGGER.")
endif()

if(USE_SPDLOGGER)
    add_definitions(-DUSE_SPDLOGGER)
elseif(USE_CUSTOMLOGGER)
    add_definitions(-DUSE_CUSTOMLOGGER)
else()
    # Default to DefaultLogger
    add_definitions(-DUSE_DEFAULTLOGGER)
endif()

add_subdirectory(3rd)
add_subdirectory(lib_wrapper)
add_subdirectory(example)
add_subdirectory(xunit_examples)